package com.sld.concrete.algorithm.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.json.JSONObject;
import com.ruoyi.common.utils.PageUtils;
import com.sld.concrete.algorithm.service.IRecCalcDataService;
import com.sld.concrete.algorithm.vo.WorkDataInfo;
import com.sld.concrete.vehicle.service.IRecDevWorkSequenceService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Controller
public class CalcDataController extends BaseController {

    @Resource
    IRecCalcDataService dataService;

    @Resource
    IRecDevWorkSequenceService sequenceService;

    @RequiresPermissions("device:calcData:view")
    @GetMapping("device/algorithm/calcDataSearch")
    public String calcDataSearch() {
        return "device/algorithm/calcDataSearch";
    }

    @PostMapping("device/algorithm/queryWorkData")
    @ResponseBody
    public TableDataInfo queryWorkData(WorkDataInfo workDataInfo) {
        PageUtils.startPage();
        List<WorkDataInfo> list = dataService.queryWorkData(workDataInfo);
        return getDataTable(list);
    }

    @GetMapping("device/algorithm/sequence-detail/{seqId}")
    public String queryWorkDetail(@PathVariable String seqId, ModelMap map) {
        Map<String,Object> res = sequenceService.queryWorkDetail(seqId);
        map.put("data",res);
        return "device/algorithm/monitor_detail";
    }

    @GetMapping("device/algorithm/getMetaData")
    @ResponseBody
    public AjaxResult queryCalculateMetaData(String calcId) {
        return AjaxResult.success(dataService.queryCalculateMetaData(calcId));
    }

}
